<?php

$page_title="Manage VOIP ";
include("includes/header.php");

$query = "SELECT * FROM bkitc_profiles where rec_status=1 ";
$membersList=qry_data($query." order by  registrant_id ");
$mode=$_GET["mode"];
$voip_reqId=$_GET["rid"];
if($mode=="edit")
{
	$voip_reqInfo=qry_data("select * from bkitc_voip where req_id=".$voip_reqId);
	$voip_req=$voip_reqInfo[0];

}

if($mode=="del" )
{

exec_qry("update bkitc_voip set rec_status=-1 where req_id=".$voip_reqId);//Soft Delete

header("location:voip_list.php");

}
?>	
<div class="fleft">
<ul class="subMenu">

<li><a href="edit_voip.php?mode=add">Add New Request</a></li>
</ul>
</div>
<div class="cleardiv"></div>
				<div style="width:100%" class="content_bg">
					<form method="post" action="edit_voip_pro.php?rid=<?=$_GET["rid"]?>" > 
						<table class="voip_form" width="100%"  cellpadding="8" border="0" cellspacing="3"> 
							

							<tr>
							<td height="10" style="padding:2px;margin:2px" colspan="2" align="right"><small style="font-size:11px"> <i><?=ast()?>  Required fields.</i></small></td>
							</tr>
							<tr >
							<td width="30%" class="frmLabel"> Full Name <?=ast()?></td>
							<td width="50%"> <input type="text" class="txtbox"  name="req_name" size="60" value="<?=$voip_req["req_name"]?>"> </td>
							</tr>
							<tr>
							<td class="frmLabel"> Email Address <?=ast()?></td>
							<td> <input type="text" class="txtbox"  name="req_email_id" size="60" value="<?=$voip_req["req_email_id"]?>"> </td>
							</tr>
							<tr>
							<td class="frmLabel"> Phone Number <?=ast()?></td>
							<td> <input type="text" class="txtbox"  name="req_phone_no" size="40" value="<?=$voip_req["req_phone_no"]?>"> </td>
							</tr>
							<tr>
							<td class="frmLabel" valign="top"> Center Address <?=ast()?></td>
							<td> <textarea class="txtarea"  rows="4" cols="50" name="req_centre_address"><?=$voip_req["req_centre_address"]?></textarea> </td>
							</tr>
							<tr>
							<td class="frmLabel"> Center-in-charge</td>
							<td> <input type="text" class="txtbox"  name="req_centre_incharge" size="50" value="<?=$voip_req["req_centre_incharge"]?>"> </td>
							</tr>
							<tr>
							<td class="frmLabel">IT contact person Name <br>(if this VoIP connection is for Centres) </td>
							<td> <input type="text" class="txtbox"  name="req_it_contact" size="50" value="<?=$voip_req["req_it_contact"]?>"> </td>
							</tr>
							<tr>
							<td class="frmLabel"> Do you have Broadband Internet connection ? <?=ast()?></td>
							<td> <input type="radio"  value="1" name="req_has_connection" id="bb_y" <?=$voip_req["req_has_connection"]==1?"checked=true":""?>><label for="bb_y"> Yes</label>&nbsp;&nbsp; <input  value="0"  type="radio" id="bb_n" name="req_has_connection" <?=$voip_req["req_has_connection"]==0?"checked=true":""?>> <label for="bb_n"> No</label> </td>
							</tr>
							<tr>
							<td class="frmLabel">Your broadband company </td>
							<td> 	
								<select class="selectbox" name="ddl_req_bb_company" onchange="setActualValue(1,this.value)" id="ddl_req_bb_company">
								<option value="">--- Please Select Provider --- </option>
								<option value="BSNL" >BSNL </option>
								<option value="Airtel">Airtel  </option>
								<option value="MTNL">MTNL </option>
								<option value="Other">Other </option>
								</select> &nbsp;<input style="display:none" name="req_bb_company" id="req_bb_company" size="15" value="<?=$voip_req["req_bb_company"];?>"  type="text" class="txtbox"	 />
							</td>
							</tr>
							<tr>
							<td class="frmLabel"> Your VoIP box model </td>
							<td> 

								<select class="selectbox" name="ddl_req_voip_model" onchange="setActualValue(2,this.value)" id="ddl_req_voip_model">
								<option value="">--- Please Select Model --- </option>
								<option value="Grandstrem 286">Grandstrem 286  </option>
								<option value="Grandstream 486">Grandstream 486   </option>
								<option value="Grandstream 502T">Grandstream 502T </option>
								<option value="Linksys PAP2">Linksys PAP2 </option>
								<option value="Other">Other </option> 
								</select> 
								&nbsp;<input style="display:none" name="req_voip_model" id="req_voip_model" size="15" value="<?=$voip_req["req_voip_model"];?>"  type="text" class="txtbox"	 />
							</td>
							</tr>
	
							<tr>
							<td colspan="2" style="border-bottom:2px solid #000;">
							<b>Official Use :</b>
							</td>
							</tr>
							<tr>
							<td class="frmLabel">Assigned VoIP No</td>
							<td> <input type="text" class="txtbox"  name="req_voip_no" size="50" value="<?=$voip_req["req_voip_no"]?>"> </td>
							</tr>
							<tr>
							<td class="frmLabel">Select Member </td>
							<td> <select class="selectbox"  style="width:600px" name="req_member_id" id="req_member_id">
							<option value="0">--- Please Select Member ---</option>
							<?foreach($membersList as $i=>$member) { ?>
							<option value="<?=$member["registrant_id"]?>">BKITC<?=number_pad($member["registrant_id"],5)." : ".$member["full_name"]." : ".$member["email_id"]." - ".$member["alternate_email_id"]?></option>
							
							<? } ?>
							</select> </td>
							</tr>
							<tr>
							<td class="frmLabel">Select Status </td>
							<td> <?=createSelect("req_status", $voip_status,  $selected = $voip_req["req_status"]==""?"":$voip_req["req_status"])?></td>
							</tr>

							<tr bgcolor="#fff" style="height:50px;margin:0px;padding:0px;">
								
								<td  style="margin:0px;padding:2px;" align="right" colspan="2">
								<input type="submit" class="button"  value="Save VoIP Info">&nbsp;
								<input class="button" type="reset">
								<input onclick="location.href='voip_list.php'"  type="button" class="button" value=" Back to VoIP List">
								</td>
							</tr>
							
						</table>
					

						
					</form>
</div>

<div style="margin-bottom:40px">

</div>
<script language="javascript">
$("link2").className="activeMenu";

var vBBCompany='<?=$voip_req["req_bb_company"]?>';
var vPhoneModel='<?=$voip_req["req_voip_model"]?>';
var vMemberId='<?=$voip_req["req_member_id"]?>';

$('ddl_req_bb_company').value=vBBCompany;
$('ddl_req_voip_model').value=vPhoneModel;
$('req_member_id').value=vMemberId;

<?if(!in_array($voip_req["req_voip_model"],$voip_model)){?>

$('ddl_req_voip_model').value="Other";
$("req_voip_model").show();
$("req_voip_model").value='<?=$voip_req["req_voip_model"]?>';

<? } ?>


<?if(!in_array($voip_req["req_bb_company"],$voip_company)){?>

$('ddl_req_bb_company').value="Other";
$("req_bb_company").show();
$("req_bb_company").value='<?=$voip_req["req_bb_company"]?>';
<? } ?>
function setActualValue(iMode,sValue){

	if(iMode==1){
		
		if(sValue=="Other") {
			$("req_bb_company").show();
			$("req_bb_company").value='';
		}
		else{
			$("req_bb_company").hide();
			$("req_bb_company").value=sValue;
		}
	}
	else{
		
		if(sValue=="Other") {
			$("req_voip_model").show();
			$("req_voip_model").value='';
		}
		else{
			$("req_voip_model").hide();
			$("req_voip_model").value=sValue;

		}
	
	}


}


</script>

<? include("includes/footer.php");?>
